package com.product.bargain.controller;

import java.util.Arrays;
import java.util.Map;

import com.product.bargain.vo.BargainShopVo;
import com.product.miaosha.vo.GoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.product.bargain.entity.BargainActivityEntity;
import com.product.bargain.service.BargainActivityService;
import com.product.common.utils.PageUtils;
import com.product.common.utils.R;



/**
 * 
 *
 * @author brh
 * @email sunlightcs@gmail.com
 * @date 2022-03-10 18:46:48
 */
@RestController
@RequestMapping("bargain/bargainactivity")
public class BargainActivityController {
    @Autowired
    private BargainActivityService bargainActivityService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bargainActivityService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		BargainActivityEntity bargainActivity = bargainActivityService.getById(id);

        return R.ok().put("bargainActivity", bargainActivity);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BargainActivityEntity bargainActivity){
		bargainActivityService.save(bargainActivity);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BargainActivityEntity bargainActivity){
		bargainActivityService.updateById(bargainActivity);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		bargainActivityService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    //商品信息
    @RequestMapping("/shopInfo/{id}")
    public BargainShopVo shopInfo(@PathVariable("id") Integer id){
        BargainShopVo shop = bargainActivityService.shopInfo(id);

        return shop;
    }

    //砍价
    @RequestMapping("/bargainShop")
    public R bargainShop(){
        
        return R.ok();
    }

}
